package com.kevin.mapping.script.node.stmt;

import com.kevin.mapping.script.engine.JSONEnv;
import com.kevin.mapping.script.lexer.Token;

import java.util.ArrayList;
import java.util.List;

public class StmtList extends Stmt {
    private List<Stmt> list;

    public StmtList(Token token) {
        super(token);
        list = new ArrayList<>();
    }

    public List<Stmt> getList() {
        return list;
    }

    public void setList(List<Stmt> list) {
        this.list = list;
    }

    @Override
    public Token execute(JSONEnv env) {
        for (int i = 0; i < list.size() - 1; i++) {
            Stmt stmt = list.get(i);
            stmt.execute(env);
        }
        return list.get(list.size() - 1).execute(env);
    }
}
